import { BaseWindow } from "../../../component/window/BaseWindow";
import { Language } from "../../../../extend/language/Language";
import { GTabBar } from "../../../../com/mui/controls/GTabBar";
import { FilterConst } from "../../../component/gconst/FilterConst";
import { MuiEvent } from "../../../../com/mui/events/MuiEvent";
import { KWAuditionsRule } from "./KWAuditionsRule";
import { KWFinalRule } from "./KWFinalRule";
import { KWGroudRule } from "./KWGroudRule";
import { View } from "../../../mvc/core/View";
type int = number;
//class KingWarRuleBaseWindow
    
    export  class KingWarRuleBaseWindow extends BaseWindow
    {
        constructor()
        {
            super();
            setSize(424, 404);
            title = Language.getString(70425);
            titleHeight = 30;
            paddingTop = 25;
            return;
        }

        /* internal  */getTabDataArray(): Array<any>
        {
            var loc1=[{"name":"rule1", "label": Language.getString(70426)}, {"name":"rule2", "label": Language.getString(70427)}, {"name":"rule3", "label": Language.getString(70428)}];
            return loc1;
        }

        protected /* override */ createChildren(): void
        {
            super.createChildren();
            this._tabData = this.getTabDataArray();
            this._tabBar = new GTabBar();
            this._tabBar.buttonWidth = 63;
            this._tabBar.height = 22;
            this._tabBar.x = 16;
            this._tabBar.y = 34;
            this._tabBar.horizontalGap = 2;
            this._tabBar.buttonFilters = [FilterConst.glowFilter];
            this._tabBar.dataProvider = this._tabData;
            this._tabBar.addEventListener(MuiEvent.GTABBAR_SELECTED_CHANGE, this.onTabBarChangeHandler);
            this.addChild(this._tabBar);
            this._audition = new KWAuditionsRule();
            this.setMainPanel(this._audition);
            return;
        }

        public showToTab(arg1: int): void
        {
            if (arg1 >= 0 && arg1 <= 2) 
            {
                this._tabBar.selectedIndex = arg1;
                this._tabBar.dispatchEvent(new MuiEvent(MuiEvent.GTABBAR_SELECTED_CHANGE));
            }
            return;
        }

        protected onTabBarChangeHandler(arg1: Object /* flash.events.Event */): void
        {
            var loc1=arg1.target.selectedIndex;
            if (loc1 != 0) 
            {
                if (loc1 != 1) 
                {
                    if (loc1 == 2) 
                    {
                        if (!this._final) 
                        {
                            this._final = new KWFinalRule();
                        }
                        this.setMainPanel(this._final);
                        return;
                    }
                }
                else 
                {
                    if (!this._groud) 
                    {
                        this._groud = new KWGroudRule();
                    }
                    this.setMainPanel(this._groud);
                }
            }
            else 
            {
                if (!this._audition) 
                {
                    this._audition = new KWAuditionsRule();
                }
                this.setMainPanel(this._audition);
            }
            return;
        }

        public setMainPanel(arg1: View): void
        {
            this._mainView = arg1;
            this._mainView.x = 18;
            this._mainView.y = 60;
            if (this._backupView) 
            {
                if (this.contains(this._backupView)) 
                {
                    this._backupView.update(null);
                    this.removeChild(this._backupView);
                }
            }
            this.addChildAt(this._mainView, 0);
            this._backupView = this._mainView;
            return;
        }

        /* internal */ /* var */_tabBar: GTabBar;

        /* internal */ /* var */_tabData: Array<any>;

        /* internal */ /* var */_mainView: View;

        /* internal */ /* var */_backupView: View;

        /* internal */ /* var */_audition: KWAuditionsRule;

        /* internal */ /* var */_groud: KWGroudRule;

        /* internal */ /* var */_final: KWFinalRule;
    }
